package pl.edu.agh.ssm.monitor.data;

import java.net.InetAddress;

public class SessionPair {

	private InetAddress address;
	private int port;
	
	public SessionPair(InetAddress address, int port) {
		super();
		this.address = address;
		this.port = port;
	}

	public InetAddress getAddress() {
		return address;
	}

	public int getPort() {
		return port;
	}
	
	@Override
	public boolean equals(Object obj) {
		if (obj instanceof SessionPair) {
			SessionPair secondSession = (SessionPair) obj;
			return this.getAddress().equals(secondSession.getAddress()) 
				&& this.getPort() == secondSession.getPort();
		}
		return false;
	}
	
	@Override
	public int hashCode() {
		return 70157 * address.hashCode() + port;
	}
	
	@Override
	public String toString() {
		return address.getHostAddress() + ":" + port;
	}
}
